import Koa, { Context } from "koa";

// 全局异常处理
const globalException = async (ctx: Context, next: Koa.Next) => {
  try {
    await next();
  } catch (err: any) {
    const errslt = err as { message: string };

    ctx.body = `服务器错误${errslt.message}`;
  }
};

export default globalException;
